Semiconductor devices have been developed in a trend of decreasing the sizes. Nowadays, the technology node has been developed to 22 nm, 14 nm, and even smaller. One approach to manufacture such a small semiconductor device is FinFET technology. A plurality of fins are disposed in a high density. Each fin comprises a source and a drain, and is surrounded by a gate. By such a structure, the gate can control the transistor more efficiently. Replacement metal gate technology has been used to further improve the efficiency of the semiconductor devices. In a replacement metal gate process, a dummy polysilicon gate may be formed and removed in a following step. However, since the fins typically have a high aspect ratio and are separated from each other by a small space, it may be difficult to completely remove a material from or fill a material into the trenches between the fins or the trenches between the fins and adjacent structural features.